//引入
import { JSEncrypt } from 'jsencrypt'
/**
 * 加密
 * @param {String}  需要加密的参数
 */
export function passwordEncryption (param) {
  // 后台给的公钥
  let publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAh/R36eWvZvpxTqoadhNNIiA/r5lDIOa43f7bU9O+GWCVEkq3ULNxWRi3NyfWeoNPMHLaZEOOBnBxrjKqlqjU21KJ5f+fInc4wkNSK0UaScLFMGkmfIjC6pjvKtC7Fy0BVlllqDXXenxA8thFud8ALMN4choLwh0rFhogr1SxkShahNxBYZnXKDGVYO4m+/2VNP3HP6ovLJVBRNEa+iLSktHO83VZKQPoa/SNTqbc69CK9fMHA/g+1jwbhheI8fXXhlTSXkkHpmT6/DTMqG024uO6dyjKdvydYPxJG7RhAlrarciiXmwojp6wJ6x6lfPc663Y7dECDPjMl4OYDvBurQIDAQAB"
  let encryptor = new JSEncrypt() // 新建JSEncrypt对象
  encryptor.setPublicKey(publicKey) // 设置公钥
  let passwordEncryp = encryptor.encrypt(param) // 对密码进行加密
  return passwordEncryp
}

// 解密
export function decrypt (msg) {
  const privateKey = ''
  let decrypt = new JSEncrypt()
  decrypt.setPrivateKey(privateKey)
  var decryptMsg = decrypt.decrypt(msg)
  return decryptMsg
}